#!/bin/sh

# Remove links, that have been relocated (see also: busybox.post-install)
for link in \
	/usr/bin/ftpget \
	/usr/bin/ftpput \
	/usr/bin/telnet \
	/usr/bin/tftp \
	/usr/sbin/ftpd \
	/usr/sbin/httpd \
	/usr/sbin/telnetd \
	/usr/sbin/tftpd \
; do
	if [ -L "$link" ] && [ "$(readlink $link)" = "/bin/busybox" ]; then
		rm "$link"
		echo "-> $(basename $link) is now in busybox-extras"
	fi
done
for link in /bin/install /bin/ip /bin/vi /usr/bin/lspci; do
	if [ -L "$link" ] && [ "$(readlink $link)" = "/bin/busybox" ]; then
		rm "$link"
	fi
done
for link in /bin/ping /bin/ping6; do
	if [ -L "$link" ] && [ "$(readlink $link)" = "/bin/bbsuid" ]; then
		rm "$link"
	fi
done

# We need the symlinks early
exec /bin/busybox --install -s
